package com.cjm.one.coupon.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.constant.SecurityConstants;
import com.cjm.one.common.constant.ServerConstants;
import com.cjm.one.common.result.Result;
import com.cjm.one.model.coupon.dto.CouponConfirmDto;
import com.cjm.one.model.coupon.dto.CouponReserveDto;
import com.cjm.one.model.coupon.entity.CustomerCoupon;
import com.cjm.one.model.coupon.vo.CouponInfoVo;
import com.cjm.one.model.coupon.vo.CouponReserveVo;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = ServerConstants.SERVER_ONE_GOODS)
public interface CustomerCouponClient {
    @GetMapping("/admin/customer/coupon/list")
    @Operation(summary = "客户领取优惠券记录列表")
    Result<Page<CustomerCoupon>> list(@RequestParam(defaultValue = "1") Integer current,
                                             @RequestParam(defaultValue = "10") Integer size,
                                      @RequestParam(name = "keyword",required = false) String keyword,
                                      @RequestParam(name = "status",required = false) Integer status,
                                      @RequestParam(name = "userId",required = false) Long userId);
    @GetMapping("/app/customer/coupon/list")
    @Operation(summary = "查询用户领取的优惠卷信息列表")
    Result<Page<CouponInfoVo>> getList(@RequestParam Long current,
                                              @RequestParam Long size ,
                                       @RequestParam(name = "keyWord", required = false) String keyWord,
                                       @RequestParam(name = "rangeType", required = false) Integer rangeType);

    @PostMapping("/app/customer/coupon/receive")
    @Operation(summary = "领取优惠券信息")
    Result<Boolean> save(@RequestBody CustomerCoupon customerCoupon);

    @PostMapping("/app/customer/coupon/batch/confirm")
    @Operation(summary = "批量确认使用")
    Result<Boolean> batchConfirmUse(
            @RequestBody  CouponConfirmDto couponConfirmDto,@RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);

    /**
     * @description: 批量预占优惠券
     * @author: cjm
     * @date: 2025/3/31 15:52
     * @param: [request]
     * @return: com.cjm.one.common.result.Result<CouponReserveResponse>
     **/
    @PostMapping("/app/customer/coupon/batch/reserve")
    @Operation(summary = "批量预占优惠券")
    Result<CouponReserveVo> batchReserveCoupons(
            @RequestBody @Valid CouponReserveDto couponReserveDto,@RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);
    @PostMapping("/app/customer/coupon/receive/auto")
    @Operation(summary = "自动领取优惠券信息")
    Result<Boolean> autoReceive(@RequestBody  CouponReserveDto couponReserveDto,@RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);
}
